package com.utc.teamcenter.common.app.base;

import java.awt.Container;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import com.teamcenter.rac.util.PropertyLayout;
import com.utc.teamcenter.common.app.dialog.bean.BeanComponent;
import com.utc.teamcenter.common.app.dialog.bean.BeanPanel;

public abstract class BaseBeanDialog extends BaseDialog {

	private static final long serialVersionUID = 1L;

	private BeanPanel beanPanel = new BeanPanel();

	public BaseBeanDialog() {
		super();
	}

	public abstract void initalBeanComponents();

	public void addBeanComponent(BeanComponent beanComponent) {
		this.beanPanel.add(beanComponent);
	}

	public BeanPanel getBeanPanel() {
		return this.beanPanel;
	}

	@Override
	public void initalDialogPanel(Container container, JTabbedPane panel) {
		JPanel beanPanel = new JPanel(new PropertyLayout());

		initalBeanComponents();

		this.beanPanel.addBeanComponentToPanel(beanPanel, 1);
//		panel.add("Information", beanPanel);
		panel.add(beanPanel);
	}

	@Override
	public void clear(Container container, JTabbedPane panel) {
		this.beanPanel.clear();
	}

	@Override
	public boolean isReady() {
		return this.beanPanel.isReady();
	}

	@Override
	public void endOperation() {
		super.endOperation();

		this.beanPanel.setEnabled(true);
	}

	@Override
	public void startOperation(String arg0) {
		super.startOperation(arg0);

		this.beanPanel.setEnabled(false);
	}
}
